<@app.html>
    <@app.head>
    <script>
        $(function () {
            $('#page_table').datagrid({
                fit: true,
                width: '100%',
                height: '100%',
                striped: true,
                pagination: true,
                url: "${contextPath}/security/hdw/item_order/page.htm",
                fitColumns: true,
                pageSize: 10,
                pageList: [10, 50, 100],
                idField: 'id',
                singleSelect: true,
                selectOnCheck: false,
                checkOnSelect: false,
                autoRowHeight: false,
                rowStyler: gridRowStyler,
                columns: [
                    [
                        {field: 'checkbox', checkbox: true},
                        {title: '订单编号', align: 'center', field: 'id'},
                        {title: '客户', align: 'center', field: 'customerMobile', width: 100},
                        {
                            title: '单格/总价(元)',
                            align: 'center',
                            field: 'price',
                            width: 60,
                            formatter: function (val, row) {
                                return new Number(row.price / 100).toFixed(2) + '/' + new Number(row.totalPrice / 100).toFixed(2)
                            }
                        },
                        {title: '数量', align: 'center', field: 'amount', width: 60},
                        {title: '订单状态', align: 'center', field: 'orderStatusName', width: 60},
                        {title: '付款时间', align: 'center', field: 'payTime', width: 100},
                        {title: '创建时间', align: 'center', field: 'createTime', width: 100}
//                        {
//                            title: '操作',
//                            align: 'center',
//                            field: 'id',
//                            width: 60,
//                            formatter: function (val, row) {
//                                var html = '<a href="javascript:view(ID)">查看</a>';
//                                return html.replace(/ID/g, row.id);
//                            }
//                        }
                    ]
                ],
                onLoadSuccess: function () {
                    $('#page_table').datagrid('clearChecked');
                    $('#page_table').datagrid('clearSelections');
                }
            });
        })


        function reload() {
            var datagrid = $('#page_table');
            datagrid.datagrid('reload');
        }

        function query() {
            var datagrid = $('#page_table');
            var customerMobile = $('#customer_mobile').val();
            var orderStatus = $('#order_status').val();
            datagrid.datagrid('options').queryParams = {
                customerMobile: customerMobile,
                orderStatus: orderStatus
            };
            datagrid.datagrid('load');
        }

        function express() {
            App.dialog.show({
                css: 'width:320px;height:194px;',
                title: '发货',
                href: "${contextPath}/security/hdw/item_order/express.htm",
                event: {
                    onClose: function () {
                        reload();
                    }
                }
            });
        }
    </script>
    </@app.head>

    <@app.body>

        <@app.container>
            <@app.banner/>

        <div class="main">
            <@app.menu/>

            <div class="content">
                <div class="panel search">
                    <div class="float_right">
                        <button class="btn btn_yellow" onclick="query()">搜索</button>
                    </div>
                    <table cellpadding="0" cellspacing="0" border="0">
                        <tr>
                            <td align="right">客户手机：</td>
                            <td><input type="text" class="text" id="customer_mobile"/></td>
                            <td align="right">订单状态：</td>
                            <td>
                                <select id="order_status">
                                    <option value="">请选择</option>
                                    <#list orderStatusEnum as e>
                                        <option value="${e.getValue()}">${e.getName()}</option>
                                    </#list>
                                </select>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="panel grid_wrap">
                    <div class="toolbar clearfix">
                        <div class="float_right">
                        <@app.has_oper oper_code='4_3_2'>
                            <button class="btn btn_green add" onclick="express()">发货</button>
                        </@app.has_oper>
                    </div>
                    <h3>商品订单</h3>
                </div>
                <div class="grid">
                    <table id="page_table"></table>
                </div>
            </div>
        </div>
        </div>
        </@app.container>
    </@app.body>
</@app.html>
